﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zocono.Infrastructure.Common;
using Zocono.WCS.Domain.DomainRepository;
using Zocono.WCS.Domain.EntityInfo;
using Zocono.WMS.Infrastructure.BaseRepository;

namespace Zocono.WCS.Infrastructure.Repository
{
    public class UserInfoRepository : BaseRepository<UserInfo>, IUserInfoRepository
    {
        public UserInfoRepository(SqlSugarClient context = null) : base(context)
        {

        }

        public async Task<bool> InitPasswordAsync(List<string> userNames)
        {
            string[] alluserName = userNames.ToArray();
            var result = await this.Context.Updateable<UserInfo>()
                 .SetColumns(it => it.Password == GenerateMD5.CreateMD5("8888"))
                  .Where(it => alluserName.Contains(it.UserName))
                 .ExecuteCommandAsync();

            return result > 0;
        }

    }
}
